package com.heima.common.minio;

import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 初始化MinIO对象
 */
@Configuration
@EnableConfigurationProperties(MinIOProperties.class) //实例化属性类
public class MinIOConfiguration {

    @Autowired
    private MinIOProperties minIOProperties;

    /**
     * 创建初始化对象
     */
    @Bean
    public MinioClient createMinIOClient(){
        return MinioClient.builder()
                .endpoint(minIOProperties.getEndpoint()) // 连接服务地址  注意：端口必须使用9000
                .credentials(minIOProperties.getAccessKey(),minIOProperties.getSecretKey())//账户和密码
                .build();
    }
}
